package dfbz.homework5;
import java.util.HashSet;
import java.util.Random;

public class Test01 {
    public static void main(String[] args) {
        HashSet<Integer> objects = new HashSet<>();
        String[] arr={"小明1","小明2","小明3","小明4","小明5","小明6","小明7","小明8","小明9","小明10"};
        for (int i = 0; i < 10; i++) {
            while (objects.size()<10){
                //生成10个数字添加1进对象
                int i1 = new Random().nextInt(100);
                objects.add(i1);
                if(objects.size()==10){
                    break;
                }
            }
        }
        System.out.println("现在有10个人,ID分别为:"+objects);
        new Thread(()-> {
                try {
                    int i=0;
                    for (Integer object : objects) {
                        Thread.sleep(5000);
                        System.out.println("正在通过的是:"+arr[i++]);
                        if(i==10){
                            break;
                        }
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
        }).start();
    }
}
